#ifndef ROBOT_H
#define ROBOT_H

#include <QThread>
#include "controller.h"
#include <QMutex>
#include <iostream>
#include "camera.h"
#include "map.h"

class Wander : public QThread
{
    Q_OBJECT
public:
    Wander();
    Wander(Controller*);
    virtual void run();
    void connectBot(Controller*);
    void wallCheck(bool &, char &);
    volatile void stop();
    void lock();
    void unlock();

private:
    QMutex mutex;
    int rightF, leftF, rightB, leftB;
    Controller *com;
    volatile bool stopped;
    int openDist;
};

class Robot : public QThread
{
    Q_OBJECT
public:
    Robot();
    virtual void run();
    void opening();
    void room();
    void intersection(char side);
    bool candle();
    void connectBot(Controller*);
    void distHeur(bool &opening, char &side);
    bool isRoom();
    volatile void killChildren();
    void lock();
    void unlock();
    void turn(char side);
    char oppDir(char side);
    void extinguish(char side);
    void turnTo(char dir);


private:
    Controller* com;
    Camera cam;
    volatile bool stopped;
    bool wandering;
    char direction;
    Wander *wander;
    QMutex mutex;
    Map maze;
    int openDist;
};

#endif // ROBOT_H
